#include "Decoder.h"
#include "Program.h"
#include "CPU.h"
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main (int argc, char *argv[]) {
	CPU cpu;	
	string prog (argv[1]);
	cout << prog << endl;
	for(int i=2; i< argc; i++)
	{
		string par (argv[i]);
		if(par == "-p")
			cpu.setPausePrint(true);
		if(par == "-s")
			cpu.setScreenMode(true);
		if(par == "-d")
		{
			string aux(argv[i+1]);
			int intAux;
			stringstream s(stringstream::in | stringstream::out);
			s << aux;
			s >> intAux;
			cout << "StartDumpPos: " << intAux << endl;
			cpu.setStartDumpPos(intAux);
			string aux1(argv[i+2]);
			stringstream sa(stringstream::in | stringstream::out);
			sa << aux1;
			sa >> intAux;
			cout << "DumpAmount: " << intAux << endl;
			cpu.setDumpAmount(intAux);
			i = i+2;
		}
	}
	Program::setCPU(&cpu);
	Program::loadProgram(prog);
	cpu.run();
}
